package com.itheima.visitor;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zzw
 * @date 2025/10/26
 * @description 访问者模式（对象结构类）
 */
public class Home {

    private final List<Animal> animalList = new ArrayList<>();

    public void action(Person person) {
        for (Animal animal : animalList) {
            animal.accept(person);
        }
    }

    // 添加元素
    public void add(Animal animal) {
        animalList.add(animal);
    }
}
